package crawler.cnki.utils;

import crawler.cnki.entity.Researcher;
import crawler.cnki.service.ResearcherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AddPaper {

    private static ResearcherService researcherService;

    @Autowired
    public void setResearcherService(ResearcherService researcherService) {
        AddPaper.researcherService = researcherService;
    }

    public static String[] urlMaker() {
        List<Researcher> researchers = researcherService.findAll();
        String[] urls = new String[researchers.size()];
        for (int i = 0; i < researchers.size(); i++) {
            String name = researchers.get(i).getName();
            String organizations = researchers.get(i).getOrganization();
            String[] organization = organizations.split(";");
            urls[i] = "http://s.wanfangdata.com.cn/periodical?q=%E4%BD%9C%E8%80%85%3A"+name+"%20作者单位%3A"+organization[0];
        }
        return urls;
    }



}
